package com.eling.elcms.travel.model;

import com.eling.elcms.basedoc.model.EnumSerializer;
import com.eling.elcms.core.dao.annotation.CriteriaEnhancer;
import com.eling.elcms.core.dao.annotation.CriteriaEnhancers;
import com.eling.elcms.core.dao.annotation.In;
import com.eling.elcms.core.dao.hibernate.OrderCriteriaEnhancer;
import com.eling.elcms.core.dao.hibernate.search.EnumBridge;
import com.eling.elcms.core.model.BaseModel;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.hibernate.search.annotations.*;

import javax.persistence.*;
/**
 * 合同签约收费
 * @author linjizeng
 *
 * 
 */
@Entity
@Table(name = "travel_contractcharge")
@Indexed
@CriteriaEnhancers(criteriaEnhancers = {
		@CriteriaEnhancer(impl = OrderCriteriaEnhancer.class)})
public class TravelContractCharge  extends BaseModel{

	private static final long serialVersionUID = 2841614836835237750L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@DocumentId
	@In
	private Long pkTravelSignUpCharge;
	
	/** 合同签约*/
	@OneToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "pkTravelContract")
	@IndexedEmbedded(depth = 1)
	private TravelContract travelContract;
	
	/** 收费方式*/
	@Enumerated(EnumType.STRING)
	@In	
	@FieldBridge(impl = EnumBridge.class)
	private PaymentMethod paymentMethod;
	
	@JsonSerialize(using = EnumSerializer.class)
	public enum PaymentMethod {
		Cash("现金"),
		WipeCard("刷卡"),
		Transfer("转账");
		private String display;

		PaymentMethod(String display) {
			this.display = display;
		}

		public String getDisplay() {
			return display;
		}
	}
	
	/** 收费状态*/
	@Enumerated(EnumType.STRING)
	@In	
	@FieldBridge(impl = EnumBridge.class)
	private PayStatus status;
	
	@JsonSerialize(using = EnumSerializer.class)
	public static enum PayStatus {
		Pay("已收费"),NoPay("待收费");
		private String display;
		PayStatus(String display) {
			this.display = display;
		}
		public String getDisplay() {
			return display;
		}
	}
	
	/** 描述 */
	@Column(length = 1023)
	@Field
	private String description;
	
	@Version
	private Integer version;

	public Long getPkTravelSignUpCharge() {
		return pkTravelSignUpCharge;
	}

	public void setPkTravelSignUpCharge(Long pkTravelSignUpCharge) {
		this.pkTravelSignUpCharge = pkTravelSignUpCharge;
	}
	
	public TravelContract getTravelContract() {
		return travelContract;
	}

	public void setTravelContract(TravelContract travelContract) {
		this.travelContract = travelContract;
	}

	public PaymentMethod getPaymentMethod() {
		return paymentMethod;
	}

	public void setPaymentMethod(PaymentMethod paymentMethod) {
		this.paymentMethod = paymentMethod;
	}

	public PayStatus getStatus() {
		return status;
	}

	public void setStatus(PayStatus status) {
		this.status = status;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Integer getVersion() {
		return version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}

}
